using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace WattsUpComponent
{

    //the class dealing with the method triggered by event.
    public class Datareceiver
    {
        double da;
        //the method used to store watts value when receiving data from power meter
        public void getwatts(object sender, WuReadingEventArgs e)
        {
            //EDIT this method to store values into the database
            this.da = e.wuData.Watts;
            System.Console.WriteLine(da);
            //EDIT this method to store values into the database
        }
    }


    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            int running = 1;
            WattsUp a = new WattsUp();
            double[] data = new double[200];
            bool b;

            b = a.Start();//start the meter to send packet to the system
            WuData myRecord = new WuData();// create a instance for storing the packet as a data structure 
            WuReadingEventArgs e = new WuReadingEventArgs(myRecord);//create eventargs for getting the packet
            Datareceiver r = new Datareceiver();//a class instance the class dealing with the method triggered by event
            a.OnWuReading += new WuReadingEventHandler(r.getwatts);//link the event with the method that would be triggered when the event happen
            a.wu_OnWuReading(myRecord);//link the data structure with the event
            while (running == 1)
            {

            }

        }
    }
}